﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace cludg.Infrastructure.Mailer
{
    public class Mailer : IMailer
    {
        public void Send(string smtpAddr, string from, IEnumerable<string> to, IEnumerable<string> cc, string subj, string body)
        {
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(from);
            if (to != null)
                foreach (var addr in to)
                    msg.To.Add(new MailAddress(addr));
            if (cc != null)
                foreach (var addr in cc)
                    msg.CC.Add(new MailAddress(addr));
            msg.Subject = subj;
            msg.Body = body;
            SmtpClient smtp = new SmtpClient(smtpAddr);
            smtp.Send(msg);
        }
    }
}
